package book_management;
/**
 * 这个还是很有意思的看看下面
 *
 */

import book_management.book.BookList;
import book_management.operation.IOperation;
import book_management.user.AdminUser;
import book_management.user.NormalUser;
import book_management.user.User;

import java.util.Scanner;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
        User user = login();//跳下面登录方法，选好角色
        BookList bookList = new BookList();
        while (true){
            int choice = user.menu();//看左面没转是吧，去看看AdminUser和NormalUser一开始你就在这里停留来着
            if(choice == -1){
                System.out.println("白白了宝儿~");
                break;
            }
            user.doOperation(choice, bookList);
        }

    }
    public static User login(){//这步走完就选好身份角色了
        System.out.println("告诉我你叫啥宝儿");
        String userName = scanner.next();
        System.out.println("欢迎大宝贝" + userName + "来这疙瘩玩儿");
        System.out.println("再问下你这回来当啥角色呀？1.普通人   0.管理员");
        int choice = scanner.nextInt();
        if(choice == 1){
            return new NormalUser(userName);
        }else
            return new AdminUser(userName);
    }
}
